package com.mtsmda.chapter3.passingVariableIntoMethod.shadowing;

class Bar {

	private int shadow = 20;

	public int getShadow() {
		return shadow;
	}

	public void setShadow(int shadow) {
		this.shadow = shadow;
	}

}

public class Shadowing2Ex {

	Bar bar = new Bar();

	static void changeBar(Bar bar){
		System.out.println("in ->");
		System.out.println("inner method begin - " + bar.getShadow());
		bar.setShadow(99);
		System.out.println("changed - " + bar.getShadow());
		bar = new Bar();
		bar.setShadow(999);
		System.out.println("local bar - " + bar.getShadow());
		System.out.println("out <-");
	}
	
	public static void main(String[] args) {
		Shadowing2Ex shadowing2Ex = new Shadowing2Ex();
		System.out.println("instance variable bar - " + shadowing2Ex.bar.getShadow());
		changeBar(shadowing2Ex.bar);
		System.out.println("after change bar - " + shadowing2Ex.bar.getShadow());
	}

}